package com.meevle.commands {
	
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.meevle.business.RecorderDelegate;
	import com.meevle.error.ErrorHandler;
	import com.meevle.events.StopRecordEvent;
	import com.meevle.model.StudioModelLocator;
	import com.meevle.model.ViewModelLocator;
	import com.meevle.vo.SlotVO;
	import com.meevle.vo.UserVO;
	
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	
	public class StopRecordCommand implements ICommand, IResponder {
		
		public function StopRecordCommand() {
			
		}
		
		// ICommand interface method
		public function execute(event:CairngormEvent):void {
			var stopRecordEvent:StopRecordEvent = event as StopRecordEvent;
			var delegate:RecorderDelegate = new RecorderDelegate(this);
			delegate.stopRecord(stopRecordEvent.user, stopRecordEvent.m_set, stopRecordEvent.slot);
			
		}
		
		//IResponder interface methods
		public function result(event:Object) : void {
				var track:SlotVO = event.result as SlotVO;
				StudioModelLocator.getInstance().isRecording = false;
				StudioModelLocator.getInstance().recordedSlot = track;
				ViewModelLocator.getInstance().error = null;
		}
		
		public function fault(event:Object) : void {
			ErrorHandler.getInstance().handleError(event as FaultEvent);
		}	
	}
}